package com.chat.chatter.ejb;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.datastore.Key;

@Entity
@Table(name="splats")
public class Splat implements Serializable {
	
	private static final long serialVersionUID = 1881413500711441952L;
	
	@Id //signifies the primary key
    //@Column(name = "SPLAT_ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key splatId;
	
	//@Column(name = "USER_ID", nullable = false, insertable = false, updatable = false)
    //private Long userId;
	
	@Basic
    private Blob splat;
	
	@ManyToOne(optional=false)
    @JoinColumn(name="USER_ID", nullable = false, referencedColumnName="USER_ID")
    private User user;
	
	public Key getSplatId() {
		return splatId;
	}

	public void setSplatId(Key splatId) {
		this.splatId = splatId;
	}

	/*public long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		System.out.println("Splat.setUserId: " + userId);
		this.userId = userId;
	}*/

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	 //void setData(byte [] data) { this.data = new Blob(data) }

	 //byte [] getData() { data?.bytes }
	public Blob getSplat() {
		return splat;
	}

	public void setSplat(Blob splat) {
		this.splat = splat;
	}

}
